# 作者：小七
# 2024年12月28日

def use_set():
    set1 = {1, 2, 3, 4, 5}
    print(set1)
    print(type(set1))
    set1 = {}
    print(type(set1))
    set1 = set()
    print(type(set1))

    fruits = {"apple", "banana", "cherry"}
    fruits.add("orange")
    print(fruits)
    x = fruits.copy()
    print(x)
    print(id(fruits), id(x))
    x = fruits
    print(id(fruits), id(x))

    x = {"apple", "banana", "cherry"}
    y = {"google", "microsoft", "apple"}
    z = x.difference(y)
    print(z)
    x.difference_update(y)
    print(x)
    print('-' * 50)
    fruits = {"apple", "banana", "cherry"}
    fruits.discard("banana")
    print(fruits)
    print('-' * 50)
    x = {"apple", "banana", "cherry"}
    z = x.symmetric_difference(y)
    print(z)
    print('-' * 50)
    z = x.union(y)
    print(z)

    print('apple' in z)
    print(x - y)
    print(x & y)
    print(x | y)
    print(x ^ y)


def use_generator():
    my_tuple = tuple(i for i in range(10))
    print(my_tuple)
    my_set = {x for x in 'abracadabra'}
    print(my_set)
    print(len(my_set))
    a = {x for x in 'abracadabra' if x not in 'abc'}
    print(a)


if __name__ == '__main__':
    # use_set()
    use_generator()
